// /////////////////////////////////////////////////////////////////////////////
//
// Name:            GameState.h
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Declaration of the GameState class.
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

#ifndef __GAMESTATE_H__
#define __GAMESTATE_H__

// Include files
#include "GameManager.h"

// Forward declarations
class GameManager;


// GameState class
//! The GameState object is a base class which is implemented through derived sub-classes.
class GameState : public ReferenceCounted, public HasSlots
{
    friend class ScriptedGameState;

public:

    // Initialisation, deinitialisation and control...
    //! Constructor
    GameState();
    //! Deconstructor
    virtual ~GameState();

    //! Initialises the GameState.
    virtual void init();
    //! Clears the GameState.
    virtual void clear();

    //! Updates the GameState.
    //! @param deltaTime     The time that has passed since the last update.
    virtual void update(f32 deltaTime);
    //! Renders the GameState.
    virtual void render();

    // Public functions
    //! Gets the ID of this state.
    u32 getID() const;
    //! Returns a pointer to the base pointer of the GameState.
    Entity* getBaseEntity() const;

    // Event functions
    //! Sends the "onUpdate" event to all entities subscribed to this state.
    //! @note For internal use only!
    void onUpdate(f32 deltaTime);
    //! Sends the "onUpdate" event to all entities subscribed to this state.
    //! @note For internal use only!
    void onRender();
    //! Sends the "onPause" event to all entities subscribed to this state.
    //! @note For internal use only!
    void onPause();
    //! Sends the "onUnPause" event to all entities subscribed to this state.
    //! @note For internal use only!
    void onUnPause();

protected:

    // Protected members
    Entity *mBaseEntity;

private:

    // Static members
    static u32 mIDCount;

    // Angelscript members
    s32 mRefCount;

    // Private members
    u32 mID;
};

#endif
